﻿using System;
using System.Collections.Generic;
using System.Text;
using Model;
using System.Net.Sockets;
using Database;
using System.Threading;
using Common;

namespace GameHelp
{
    public partial class Operationer
    {
        #region 命令代码定义-进入副本
        /// <summary>
        /// 进入30简单副本，倒数第一个字节为副本模式：0x01为简单，0x02为困难
        /// 倒数第二个字节为副本代码：0x01-30副本，0x02-50副本，0x03-70副本，0x04-80副本，0x05-90副本
        /// </summary>
        public static byte[] RadioEasy30EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x01, 0x01 };
        /// <summary>
        /// 进入30困难副本
        /// </summary>
        public static byte[] RadioHard30EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x01, 0x02 };
        /// <summary>
        /// 30困难副本进入下一层
        /// </summary>
        public static byte[] RadioHard30NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x01, 0x02, 0x02 };
        /// <summary>
        /// 30简单副本进入下一层
        /// </summary>
        public static byte[] RadioEasy30NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x01, 0x01, 0x02 };
        /// <summary>
        /// 进入50简单副本
        /// </summary>
        public static byte[] RadioEasy50EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x02, 0x01 };
        /// <summary>
        /// 进入50困难副本
        /// </summary>
        public static byte[] RadioHard50EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x02, 0x02 };
        /// <summary>
        /// 50困难副本进入下一层
        /// </summary>
        public static byte[] RadioHard50NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x02, 0x02, 0x02 };
        /// <summary>
        /// 50简单副本进入下一层
        /// </summary>
        public static byte[] RadioEasy50NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x02, 0x01, 0x02 };
        /// <summary>
        /// 进入70简单副本
        /// </summary>
        public static byte[] RadioEasy70EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x03, 0x01 };
        /// <summary>
        /// 进入70困难副本
        /// </summary>
        public static byte[] RadioHard70EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x03, 0x02 };
        /// <summary>
        /// 70困难副本进入下一层
        /// </summary>
        public static byte[] RadioHard70NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x03, 0x02, 0x24 };
        /// <summary>
        /// 70困难副本进入下一层
        /// </summary>
        public static byte[] RadioEasy70NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x03, 0x01, 0x24 };

        /// <summary>
        /// 进入80简单副本
        /// </summary>
        public static byte[] RadioEasy80EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x04, 0x01 };
        /// <summary>
        /// 进入80困难副本
        /// </summary>
        public static byte[] RadioHard80EnterCode = new byte[] { 0x03, 0x00, 0xFF, 0x58, 0x00, 0x04, 0x02 };
        /// <summary>
        /// 80简单副本进入下一层
        /// </summary>
        public static byte[] RadioEasy80NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x04, 0x02, 0x24 };
        /// <summary>
        /// 80困难副本进入下一层
        /// </summary>
        public static byte[] RadioHard80NextFightCode = new byte[] { 0x03, 0x00, 0xFF, 0x5A, 0x04, 0x01, 0x24 };
        #endregion

        #region 命令代码定义-战斗
        /// <summary>
        /// 战斗结束
        /// </summary>
        public static byte[] FightCompleteCode = new byte[] { 0x00, 0x00, 0xFF, 0x77 };
        /// <summary>
        /// 战斗计时代码
        /// </summary>
        public static byte[] FightTimeCode = new byte[] { 0x09, 0x00, 0xFF, 0x0F, 0x00, 0xF3, 0x07 };

        /// <summary>
        /// 攻击怪物代码，后面加上4字节怪物代码
        /// </summary>
        public static byte[] AttackMonsterCode = new byte[] { 0x04, 0x00, 0xFF, 0x61 };
        /// <summary>
        /// 战斗失败代码
        /// </summary>
        public static byte[] FightLostCode = new byte[] { 0x05, 0x00, 0xFF, 0x15, 0x50, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 自动挂机代码，后面加上4字节怪物代码
        /// </summary>
        public static byte[] AutoAttackMonsterCode = new byte[] { 0x04, 0x00, 0xFF, 0x6D };
        /// <summary>
        /// 80级自动挂机代码
        /// </summary>
        public static byte[] AutoAttackMonster80Code = new byte[] { 0x04, 0x00, 0xFF, 0x6D, 0x79, 0x11, 0x00, 0x00 };
        /// <summary>
        /// 81级自动挂机代码
        /// </summary>
        public static byte[] AutoAttackMonster81Code = new byte[] { 0x04, 0x00, 0xFF, 0x6D, 0x7A, 0x11, 0x00, 0x00 };
        /// <summary>
        /// 82级自动挂机代码
        /// </summary>
        public static byte[] AutoAttackMonster82Code = new byte[] { 0x04, 0x00, 0xFF, 0x6D, 0x6D, 0x11, 0x00, 0x00 };
        /// <summary>
        /// 83级自动挂机代码
        /// </summary>
        public static byte[] AutoAttackMonster83Code = new byte[] { 0x04, 0x00, 0xFF, 0x6D, 0x6E, 0x11, 0x00, 0x00 };
        /// <summary>
        /// 85级自动挂机代码
        /// </summary>
        public static byte[] AutoAttackMonster85Code = new byte[] { 0x04, 0x00, 0xFF, 0x6D, 0x70, 0x11, 0x00, 0x00 };
        #endregion

        #region 代码定义-怪物
        public static byte[] Monster黑风兽Code = new byte[] { 0x71, 0x10, 0x00, 0x00 };
        public static byte[] Monster僵尸刺客Code = new byte[] { 0x7c, 0x10, 0x00, 0x00 };
        public static byte[] Monster怨灵鬼魂Code = new byte[] { 0x6A, 0x10, 0x00, 0x00 };
        public static byte[] Monster渔人头目Code = new byte[] { 0x89, 0x10, 0x00, 0x00 };
        public static byte[] Monster裂化渔人LV75 = new byte[] { 0xD7, 0x10, 0x00, 0x00 };
        public static byte[] Monster邪毒水妖LV76 = new byte[] { 0xD8, 0x10, 0x00, 0x00 };
        public static byte[] Monster血浸骷髅LV77 = new byte[] { 0xDB, 0x10, 0x00, 0x00 };
        public static byte[] Monster绝地霸王龙LV79 = new byte[] { 0x09, 0x11, 0x00, 0x00 };
        public static byte[] Monster火焰霸王龙LV80 = new byte[] { 0x79, 0x11, 0x00, 0x00 };
        public static byte[] Monster魔犬LV81 = new byte[] { 0x7A, 0x11, 0x00, 0x00 };
        public static Monster Monster绝境冰妖LV78 = new Monster("绝境冰妖", 78, new byte[] { 0xDF, 0x10, 0x00, 0x00 });
        public static Monster Monster岩岛毒蛇LV73 = new Monster("岩岛毒蛇", 73, new byte[] { 0xD4, 0x10, 0x00, 0x00 });
        //D8 10 00 00 
        #endregion

        #region 命令代码定义-任务
        /// <summary>
        /// 接受任务的代码，后面跟4个字节的任务代码，在后面跟1个字节0x00，在后面跟6个字节0
        /// 提交任务的代码，后面跟4个字节的任务代码，在后面跟1个字节0x01，在后面跟6个字节0
        /// 放弃任务的代码，后面跟4个字节的任务代码，在后面跟1个字节0x02，在后面跟6个字节0
        /// </summary>
        public static byte[] TakeQuestCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85 };

        /// <summary>
        /// 刷新经验道长的循环任务的颜色
        /// </summary>
        public static byte[] FlushQuestColor = new byte[] { 0x0A, 0x00, 0xFF, 0x8B, 0xEB, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 刷新循环任务的返回数据开头
        /// </summary>
        public static byte[] FlushQuestColorReturn = new byte[] { 0x09, 0x00, 0xFF, 0x8B, 0xEB, 0x03, 0x00, 0x00 };
        /// <summary>
        /// 查询循环任务当前信息
        /// </summary>
        public static byte[] QueryQuestInfo = new byte[] { 0x04, 0x00, 0xFF, 0x80, 0xF4, 0x10, 0x00, 0x00 };
        /// <summary>
        /// 查询循环任务当前信息的返回结果
        /// </summary>
        public static byte[] QueryQuestInfoResult = new byte[] { 0xFF, 0x8A, 0xF4, 0x10, 0x00, 0x00, 0xEB, 0x03, 0x00, 0x00 };
        #endregion

        #region 命令代码定义-副本任务
        /// <summary>
        /// 接受30困难副本任务A
        /// </summary>
        public static byte[] QuestacceptRadio30ACode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE5, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交30困难副本任务A
        /// </summary>
        public static byte[] FinshQuestRadio30ACode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE5, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 接受30困难副本任务B
        /// </summary>
        public static byte[] QuestacceptRadio30BCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE6, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交30困难副本任务B
        /// </summary>
        public static byte[] FinshQuestRadio30BCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE6, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 接受30困难副本任务C
        /// </summary>
        public static byte[] QuestacceptRadio30CCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE7, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交30困难副本任务C
        /// </summary>
        public static byte[] FinshQuestRadio30CCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE7, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        //0B 00 FF 85 E8 38 01 00 00 00 00 00 00 00 00 

        /// <summary>
        /// 接受50困难副本任务A
        /// </summary>
        public static byte[] QuestacceptRadio50ACode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE8, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交50困难副本任务A
        /// </summary>
        public static byte[] FinshQuestRadio50ACode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE8, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 接受50困难副本任务B
        /// </summary>
        public static byte[] QuestacceptRadio50BCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE9, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交50困难副本任务B
        /// </summary>
        public static byte[] FinshQuestRadio50BCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xE9, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 接受50困难副本任务C
        /// </summary>
        public static byte[] QuestacceptRadio50CCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xEA, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交50困难副本任务C
        /// </summary>
        public static byte[] FinshQuestRadio50CCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xEA, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };


        /// <summary>
        /// 接受70困难副本任务A
        /// </summary>
        public static byte[] QuestacceptRadio70ACode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xEE, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交70困难副本任务A
        /// </summary>
        public static byte[] FinshQuestRadio70ACode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xEE, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 接受70困难副本任务B
        /// </summary>
        public static byte[] QuestacceptRadio70BCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xED, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交70困难副本任务B
        /// </summary>
        public static byte[] FinshQuestRadio70BCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xED, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 接受70困难副本任务C
        /// </summary>
        public static byte[] QuestacceptRadio70CCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xEC, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交70困难副本任务C
        /// </summary>
        public static byte[] FinshQuestRadio70CCode = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xEC, 0x38, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        #endregion

        #region 命令代码定义-老板娘日常任务
        /// <summary>
        /// 接受任务：烽烟再起
        /// </summary>
        static byte[] QuestacceptDaily1Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xAB, 0x12, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 烽烟再起任务接受成功返回的代码关键字
        /// </summary>
        static byte[] QuestacceptDaily1CodeOK = new byte[] { 0xFF, 0x85, 0xAB, 0x12, 0x01 };
        /// <summary>
        /// 完成任务：烽烟再起
        /// </summary>
        static byte[] FinishQuestDaily1Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xAB, 0x12, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交任务：烽烟再起 成功返回的代码字符串
        /// </summary>
        static string FinishQuestDaily1CodeOK = "完成任务[5:70315]";

        /// <summary>
        /// 接受任务：老板娘叫你回家吃饭
        /// </summary>
        static byte[] QuestacceptDaily2Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0x67, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 老板娘叫你回家吃饭任务接受成功返回的代码关键字
        /// </summary>
        static byte[] QuestacceptDaily2CodeOK = new byte[] { 0xFF, 0x85, 0x67, 0x13, 0x01 };
        /// <summary>
        /// 提交任务：老板娘叫你回家吃饭
        /// </summary>
        static byte[] FinishQuestDaily2Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0x67, 0x13, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交任务老：板娘叫你回家吃饭 成功返回的代码字符串
        /// </summary>
        static string FinishQuestDaily2CodeOK = "完成任务[5:70503]";

        /// <summary>
        /// 接受任务：有人的地方就有江湖
        /// </summary>
        static byte[] QuestacceptDaily3Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0x68, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 有人的地方就有江湖任务接受成功返回的代码关键字
        /// </summary>
        static byte[] QuestacceptDaily3CodeOK = new byte[] { 0xFF, 0x85, 0x68, 0x13, 0x01 };
        /// <summary>
        /// 完成任务：有人的地方就有江湖
        /// </summary>
        static byte[] FinishQuestDaily3Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0x68, 0x13, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交任务:有人的地方就有江湖 成功返回的代码字符串
        /// </summary>
        static string FinishQuestDaily3CodeOK = "完成任务[5:70504]";

        /// <summary>
        /// 接受任务：人争一口气
        /// </summary>
        static byte[] QuestacceptDaily4Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xAD, 0x12, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 接受任务：人争一口气 成功返回的代码关键字
        /// </summary>
        static byte[] QuestacceptDaily4CodeOK = new byte[] { 0xFF, 0x85, 0xAD, 0x12, 0x01 };
        /// <summary>
        /// 完成任务：人争一口气
        /// </summary>
        static byte[] FinishQuestDaily4Code = new byte[] { 0x0B, 0x00, 0xFF, 0x85, 0xAD, 0x12, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 提交任务:人争一口气 成功返回的代码字符串
        /// </summary>
        static string FinishQuestDaily4CodeOK = "完成任务[5:70317]";
        #endregion

        #region 命令代码定义-传送，地址
        /// <summary>
        /// 传送命令，传送命令代码+2个字节地址代码
        /// </summary>
        static byte[] TransmitCode = new byte[] { 0x02, 0x00, 0xFF, 0x51 };
        /// <summary>
        /// 黑风岗
        /// </summary>
        static byte[] Address黑风岗Code = new byte[] { 0x02, 0x23 };
        /// <summary>
        /// 黑森林
        /// </summary>
        static byte[] Address黑森林Code = new byte[] { 0x04, 0x31 };
        /// <summary>
        /// 战争废墟
        /// </summary>
        static byte[] Address战争废墟Code = new byte[] { 0x04, 0x22 };
        /// <summary>
        /// 码头废墟
        /// </summary>
        static byte[] Address码头废墟Code = new byte[] { 0x02, 0x33 };
        /// <summary>
        /// 海市桥-海波流
        /// </summary>        
        static Address Address海波流 = new Address("海波流", new byte[] { 0x01, 0x63, 0x00, 0x00 });
        #endregion

        #region 命令代码定义-购买，出售等
        /// <summary>
        /// 背包空间不足代码
        /// </summary>
        static byte[] NotEnoughSpace = new byte[] { 0x09, 0x00, 0xFF, 0x0F, 0x02, 0xDD, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 购买便捷返血符100个
        /// </summary>
        static byte[] BuyHP10000x100Code = new byte[] { 0x05, 0x00, 0xFF, 0xB1, 0x05, 0x2B, 0x23, 0x64, 0x00 };
        /// <summary>
        /// 使用便捷返血符10个
        /// </summary>
        static byte[] UseHP10000x10Code = new byte[] { 0x0B, 0x00, 0xFF, 0x33, 0x2B, 0x23, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00 };
        /// <summary>
        /// 使用物品命令代码
        /// </summary>
        static byte[] UseCode = new byte[] { 0x0B, 0x00, 0xFF, 0x33 };
        /// <summary>
        /// 用银币购买物品命令代码
        /// </summary>
        static byte[] BuyCodeSlive = new byte[] { 0x05, 0x00, 0xFF, 0xB1, 0x06 };//05 00 FF B1 06 E2 22 01 00 
        /// <summary>
        /// 用铜币购买物品命令代码
        /// </summary>
        static byte[] BuyCodeCopper = new byte[] { 0x05, 0x00, 0xFF, 0xB1, 0x05 };
        /// <summary>
        /// 用元宝购买物品命令代码
        /// </summary>
        static byte[] BuyCodeGold = new byte[] { 0x05, 0x00, 0xFF, 0xB1, 0x05 };
        /// <summary>
        /// 用礼券购买物品命令代码
        /// </summary>
        static byte[] BuyCodeGiftCertificate = new byte[] { 0x05, 0x00, 0xFF, 0xB1, 0x05 };
        /// <summary>
        /// 使用物品失败返回的代码前4个字节
        /// </summary>
        static byte[] UseItemFailedCode = new byte[] { 0x06, 0x00, 0xFF, 0x33 };

        /// <summary>
        /// 出售物品代码
        /// </summary>
        static byte[] SellItemCode = new byte[] { 0x09, 0x00, 0xFF, 0x32, 0x01, 0x00 };
        #endregion

        #region 代码定义-物品
        /// <summary>
        /// 便捷返血符代码，使用提供10000点HP自动恢复
        /// </summary>
        static byte[] Item便捷返血符 = new byte[] { 0x2B, 0x23 };
        /// <summary>
        /// 自动回血符，自动补充100万HP
        /// </summary>
        static byte[] Item自动回血符 = new byte[] { 0xE2, 0x22 };
        /// <summary>
        /// 初级单体增强符，使用全属性增加5%
        /// </summary>
        static byte[] Item初级单体增强符 = new byte[] { 0xCC, 0x22 };
        /// <summary>
        /// 初级群体增强符，使用全属性增加5%
        /// </summary>
        static byte[] Item初级群体增强符 = new byte[] { 0xCF, 0x22 };
        #endregion

        #region 命令执行返回成功的代码

        #endregion

        #region 代码定义-系统
        //04 00 FF 00 B9 88 05 00
        /// <summary>
        /// 客户端向服务器发送的在线检测代码
        /// </summary>
        static byte[] SysCheckOnline = new byte[] { 0x04, 0x00, 0xFF, 0x00, 0xB9, 0x88, 0x05, 0x00 };
        /// <summary>
        /// 服务端返回的角色信息的数据开始
        /// </summary>
        static byte[] SysCharactersInfoStart = new byte[] { 0x14, 0x00, 0xFF, 0x98, 0x01 };

        /// <summary>
        /// 服务端返回的角色信息的数据开始A，用于获取银币礼券等信息
        /// </summary>
        static byte[] SysCharactersInfoStartA = new byte[] { 0xFF, 0x14, 0x00 };
        #endregion

        #region 字符串定义
        static string SellSucess = "出售物品成功";
        #endregion

        #region 功能命令
        /// <summary>
        /// 出售给定的物品
        /// </summary>
        /// <param name="item">要出售的物品</param>
        /// <param name="amount">要出售的数量</param>
        /// <returns>出售成功返回true，失败或者超时返回false</returns>
        public bool SellItem(TdyxObjects item, int amount)
        {
            OperationWaitResultPoint getSellItemResultPoint = new OperationWaitResultPoint(30);
            getSellItemResultPoint.Method = new OperationWaitResult(delegate(byte[] datas, int length, OperationWaitResultPoint point)
            {
                bool sucess = GetSellResult(datas, length);
                if (sucess)
                {
                    point.Sucess = true;
                    point.Stoped = true;
                    return true;
                }
                return false;
            });
            byte[] amountByte = new byte[3];
            amountByte[1] = (byte)amount;
            waitResultMethod.Add(getSellItemResultPoint);
            Forward(Tools.Contact(SellItemCode, item.Code, amountByte));
            return WaitCommandSucess(getSellItemResultPoint);
        }

        /// <summary>
        /// 使用物品
        /// </summary>
        /// <param name="itemCode">物品代码</param>
        /// <param name="number">数量</param>
        /// <returns></returns>
        private bool UserItem(byte[] itemCode, int number)
        {
            Forward(Tools.Contact(UseCode, itemCode, new byte[] { 0, 0, 0, (byte)number, 0, 0, 0, 0, 0 }));
            return true;
        }

        /// <summary>
        /// 购买物品
        /// </summary>
        /// <param name="itemCode">物品代码</param>
        /// <param name="number">数量</param>
        /// <returns></returns>
        private bool UserItem(byte[] itemCode, int number, MeonyType type)
        {
            byte[] num = new byte[] { (byte)number, 0 };
            switch (type)
            {
                case MeonyType.Slive://用银币购买
                    Forward(Tools.Contact(BuyCodeSlive, itemCode, num));
                    break;
                case MeonyType.Copper://铜币
                    Forward(Tools.Contact(BuyCodeCopper, itemCode, num));
                    break;
                case MeonyType.Gold://元宝
                    Forward(Tools.Contact(BuyCodeGold, itemCode, num));
                    break;
                case MeonyType.GiftCertificate://礼券
                    Forward(Tools.Contact(BuyCodeGiftCertificate, itemCode, num));
                    break;
            }
            return true;
        }

        /// <summary>
        /// 结束战斗
        /// </summary>
        /// <returns></returns>
        public bool FinshFight()
        {
            Forward(Operationer.FightCompleteCode, Operationer.FightCompleteCode.Length, serverClient);
            return true;
        }


        /// <summary>
        /// 根据等级自动挂机
        /// </summary>
        /// <returns></returns>
        public bool AutoGuji()
        {
            Monster monster = MonsterDatabase.GetFirstMonster(account.Character.LV);
            if (monster != null)
            {
                //避免已经处于挂机状再次发送挂机命令导致挂机取消，先传送2个地方，然后在挂机
                byte[] datas = Tools.Contact(Operationer.TransmitCode, Operationer.Address黑风岗Code);
                MessageWrite(account, "移动到黑风岗");
                Forward(datas);
                Thread.Sleep(300);
                datas = Tools.Contact(Operationer.TransmitCode, Operationer.Address黑森林Code);
                MessageWrite(account, "移动到黑森林");
                Forward(datas);
                Thread.Sleep(300);
                Forward(Tools.Contact(Operationer.AutoAttackMonsterCode, monster.Code));//根据等级自动挂机
                MessageWrite(account, "开始自动挂机，挂机怪物：" + monster.Name);
            }
            else
            {
                MessageWrite(account, "数据库里没有找到等级为" + account.Character.LV + "的怪物，不能自动挂机。");
            }

            return true;
        }

        /// <summary>
        /// 传送到目的地址，返回传送是否成功
        /// </summary>
        /// <param name="addr">地址数据</param>
        /// <returns></returns>
        private bool Transmit(Address addr)
        {
            byte[] addrDatas = Tools.Contact(TransmitCode, addr.Code);
            //OperationWaitResultPoint getTransResultPoint = new OperationWaitResultPoint();
            //getTransResultPoint.Timeout = 5;
            //getTransResultPoint.Method = new OperationWaitResult(delegate(byte[] datas, int length, OperationWaitResultPoint point)
            //{
            //    if (Tools.Compare(addrDatas, datas))
            //    {
            //        point.Message = "命令：传送到" + addr.Name + "成功.";
            //        point.Sucess = true;
            //        point.Stoped = true;
            //        return true;
            //    }

            //    //超时则移除结果验证方法
            //    if (point.IsTimeout)
            //    {
            //        point.Message = "命令：传送到" + addr.Name + "已超时.";
            //        return true;
            //    }
            //    return false;
            //});
            //this.waitResultMethod.Add(getTransResultPoint);
            MessageWrite(account, "传送到 " + addr.Name);
            Forward(addrDatas);
            return true;
        }

        /// <summary>
        /// 使用给定的战斗时间攻击指定怪物
        /// </summary>
        /// <param name="monster">要攻击的怪物</param>
        /// <param name="time">战斗时间，单位秒</param>
        /// <returns>战斗结果</returns>
        private FightResult AttackMonster(Monster monster, int time)
        {
            MessageWrite(account, "攻击怪物：" + monster.Name);
            FightResult result = new FightResult(false);
            Forward(Tools.Contact(AttackMonsterCode, monster.Code));
            Thread.Sleep(time);
            MessageWrite(account, "战斗结束." );
            Forward(FightCompleteCode);
            return result;
        }

        /// <summary>
        /// 接受给定的任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        private bool TakeTask(Task task)
        {
            MessageWrite(account, "接受任务："+task.Name);
            Forward(Tools.Contact(Operationer.TakeQuestCode, task.Code, new byte[] { 0x00 }, new byte[] { 0, 0, 0, 0, 0, 0 }));
            return true;
        }

        /// <summary>
        /// 提交给定的任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        private bool CompleteTask(Task task)
        {
            MessageWrite(account, "提交任务：" + task.Name);
            getExpListener.Enabled = true;
            Forward(Tools.Contact(Operationer.TakeQuestCode, task.Code, new byte[] { 0x01 }, new byte[] { 0, 0, 0, 0, 0, 0 }));
            return getExpListener.Wait();            
        }

        /// <summary>
        /// 放弃给定的任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        private bool QuitTask(Task task)
        {
            MessageWrite(account, "放弃任务：" + task.Name);
            Forward(Tools.Contact(Operationer.TakeQuestCode, task.Code, new byte[] { 0x01 }, new byte[] { 0, 0, 0, 0, 0, 0 }));
            return true;
        }
        #endregion

        #region 游戏命令结果检测
        /// <summary>
        /// 等待操作执行结果
        /// </summary>
        /// <param name="point">操作执行验证类</param>
        /// <param name="waitTimeout">超时时间，单位秒</param>
        /// <returns>操作成功执行返回true，否则返回false，超时返回false</returns>
        private bool WaitCommandSucess(OperationWaitResultPoint point, int waitTimeout)
        {
            while (!point.Sucess)
            {
                waitTimeout--;
                if (waitTimeout == 0)
                {
                    return false;
                }
                Thread.Sleep(999);
            }
            return true;
        }

        /// <summary>
        /// 等待操作执行结果
        /// </summary>
        /// <param name="point">操作执行验证类</param>
        /// <returns>操作成功执行返回true，否则返回false，超时返回false</returns>
        private bool WaitCommandSucess(OperationWaitResultPoint point)
        {
            while (!point.Sucess)
            {
                //point.Timeout--;
                if (point.IsTimeout)
                {
                    return false;
                }
                Thread.Sleep(999);
            }
            return true;
        }

        /// <summary>
        /// 检测30困难副本是否通关
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        private bool FightRadio30Sucess(byte[] datas, int length)
        {
            string s = UTF8Encoding.UTF8.GetString(datas, 0, length);
            if (s.IndexOf(account.Character.Name) > -1)
            {
                if (s.IndexOf("焚骨窟") > -1 && s.IndexOf("获得了") > -1)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// 检测50苦难副本是否通关
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        private bool FightRadio50Sucess(byte[] datas, int length)
        {
            string s = UTF8Encoding.UTF8.GetString(datas, 0, length);
            if (s.IndexOf(account.Character.Name) > -1)
            {
                if (s.IndexOf("天人福邸") > -1 && s.IndexOf("获得了") > -1)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// 检测70困难副本是否通关
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        private bool FightRadio70Sucess(byte[] datas, int length)
        {
            string s = UTF8Encoding.UTF8.GetString(datas, 0, length);
            if (s.IndexOf(account.Character.Name) > -1)
            {
                if (s.IndexOf("困仙阵") > -1 && s.IndexOf("第44层获得了") > -1)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// 检测80困难副本是否通关
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        private bool FightRadio80Sucess(byte[] datas, int length)
        {
            string s = UTF8Encoding.UTF8.GetString(datas, 0, length);
            if (s.IndexOf(account.Character.Name) > -1)
            {
                if (s.IndexOf("困仙阵") > -1 && s.IndexOf("第44层获得了") > -1)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// 返回可以进行下次战斗的计时，单位秒
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public int GetNextFightTime(byte[] datas, int length)
        {
            if (length > 7)
            {
                if (datas[0] == 0x09 && datas[1] == 0x00 && datas[2] == 0xff && datas[3] == 0x0f
                    && datas[4] == 0x00 && datas[5] == 0xf3 && datas[6] == 0x07)
                {
                    return (int)datas[9];
                }
            }
            return -1;
        }

        /// <summary>
        /// 返回给定的字节数据是否包含出售物品是否成功的信息
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public bool GetSellResult(byte[] datas, int length)
        {
            string dataString = Encoding.UTF8.GetString(datas, 0, length);
            if (dataString.IndexOf(SellSucess) > -1)
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// 获取循环任务的名字
        /// </summary>
        /// <param name="datas"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public string GetExpTaskName(byte[] datas, int length)
        {
            byte[] dataTemp = new byte[length];
            for (int i = 0; i < length; i++)
            {
                dataTemp[i] = datas[i];
            }
            string temp = UTF8Encoding.UTF8.GetString(dataTemp);
            return temp.Substring(33);//任务名字从第33个字节开始
        }
        #endregion
    }
}